
OBJECTS= CUDA_vec.o\
 CUDA_full_weighting.o\
 CUDA_interpolation.o\
 CUDA_Poisson.o\
 utility.o\
 MultigridSolver.o\
 test.o

LINK_TARGET = test

TEST_TARGET = test_components

REBUILDABLES = ${OBJECTS} ${LINK_TARGET}

CPPLINKER= g++ -arch i386

CUDA_INSTALL_PATH = /usr/local/cuda
NVCC = $(CUDA_INSTALL_PATH)/bin/nvcc

CUDAINCLUDES= -I${CUDA_INSTALL_PATH}/include -I/Developer/GPU\ Computing/C/common/inc 
CUDALIBS= -lcuda -lcudart -lm
CUDAFLAGS = -g -G --ptxas-options=-v

.PHONY: all clean

.SUFFIXES: .cpp .cu

.cpp.o:
	${CPPLINKER} -c $<

.cu.o:
	${NVCC} ${CUDAFLAGS} ${CUDAINCLUDES} ${CUDALIBS} -c $<

${LINK_TARGET}: ${OBJECTS} ${LINK_TARGET}.o
	${NVCC} ${CUDAFLAGS} ${INCLUDES} ${LIBS} $^ -o ${LINK_TARGET}

${TEST_TARGET}: ${OBJECTS} testComponents.o
	${NVCC} ${CUDAFLAGS} ${INCLUDES} ${LIBS} $^ -o ${TEST_TARGET}
	
deviceStats: deviceStats.cu
	${NVCC} ${CUDAFLAGS} ${INCLUDES} ${LIBS} $^ -o deviceStats
	
cuPrintf.o: cuPrintf.cuh cuPrintf.cu

reduce_test: testReduce.cu utility.o CUDA_vec.o 
	${NVCC} ${CUDAFLAGS} ${CUDAINCLUDES} ${CUDALIBS} $^ -o reduce_test

matMultTest: matMultTest.cu CUDA_vec.o CUDA_Poisson.o utility.o
	${NVCC} ${CUDAFLAGS} ${CUDAINCLUDES} ${CUDALIBS} $^ -o matMultTest 

CUDA_vec.o: CUDA_vec.h CUDA_vec.cu utility.o Reduce.h

CUDA_full_weighting.o: CUDA_full_weighting.h CUDA_full_weighting.cu utility.o

CUDA_interpolation.o: CUDA_interpolation.h CUDA_interpolation.cu

CUDA_Poisson.o: CUDA_Poisson.h CUDA_Poisson.cu

CUDA_JacobiRelax.o: CUDA_JacobiRelax.h CUDA_JacobiRelax.cu CUDA_vec.h

ConjugateGradient.o: ConjugateGradient.h ConjugateGradient.cpp

utility.o: utility.h utility.cu

MultigridSolver.o: MultigridSolver.h MultigridSolver.cu CUDA_vec.o CUDA_full_weighting.o CUDA_JacobiRelax.h CUDA_interpolation.o ConjugateGradient.h

test.o: test.cu CUDA_vec.o MultigridSolver.h CUDA_Poisson.o

testComponents.o: testComponents.cu CUDA_vec.o CUDA_full_weighting.o CUDA_interpolation.o CUDA_Poisson.o utility.o

clean:
	-rm ${REBUILDABLES}